//
//  LHDownloadDetailViewController.m
//  Knight_Tour
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHUserRecommendSightDetailViewController.h"
#import "LHRecommendSightDetailUserView.h"
#import "MyNavgationView.h"
#import "LHRecommendSightDetailViewController.h"

@interface LHUserRecommendSightDetailViewController ()<jumpToRecommendSightDeledate>
@property (nonatomic ,retain) NSMutableArray *recommendSightArr;
@property (nonatomic ,retain) LHRecommendSightDetailUserView *SDVC;
@end

@implementation LHUserRecommendSightDetailViewController

- (void)dealloc
{
    [_recommendSightArr release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.hidden = YES;
    self.recommendSightArr = [NSMutableArray array];
    
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    [self getManagerWithLHRecommendSight];
    [self createNavigation];
    [self createTableView];
    
    
}

- (void)createTableView
{
    self.SDVC = [[LHRecommendSightDetailUserView alloc] initWithFrame:CGRectMake(0, 64, LHWidth, LHheight - 64)];
    _SDVC.modelArr = self.recommendSightArr;
    _SDVC.delegate = self;
    [self.view addSubview:_SDVC];
    [_SDVC release];
}

- (void)createNavigation
{
    MyNavgationView *myNV = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    [myNV creatTitle:@"我的推荐景点"];
    
    myNV.leftTarget = self;
    myNV.leftAction = @selector(backToUser);
    [myNV creatLeftButtonWithImage:@"btn_nav_back"];
 
    [self.view addSubview:myNV];
    [myNV release];
}

-(void) getManagerWithLHRecommendSight
{
    NSString *path = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"LHRecommendSight"] stringByAppendingPathComponent:@"LHRecommendSight.kk"];
        self.recommendSightArr = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
}

-(void)jumpToRecommendSight:(NSIndexPath *)index
{
    LHRecommendSightDetailViewController *vc = [[LHRecommendSightDetailViewController alloc]init];
    vc.sightDetailModel = self.recommendSightArr[index.row];
    [self.navigationController pushViewController:vc animated:YES];
    [vc release];
}

- (void)backToUser
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
